<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:pe="http://primefaces.org/ui/extensions">
    <h:head>
        <title>#{bundle.savclosure}</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition>
            <h:form prependId="false">
               <script type="text/javascript">  
                   var tofocus;
                   
                   function changeFocus(nextfcs) {tofocus=nextfcs;}
                   
                   function focusState(xhr, status, args) {  
                       //if(args.validationFailed || !args.success) {}
                      // else document.getElementById(tofocus).focus();
                       return false;
                   }
                   
                   function customRK(e, id, nextfcs) {
                      var code = (e.keyCode ? e.keyCode : e.which);
                       if(code==13) {
                            
                            if (id=="savclosureSavingNo") {
                               rcsavclosureGetSaving();
                               tofocus=nextfcs;
                            } 
                            
                            e.preventDefault ? e.preventDefault() : e.returnValue = false;
                            e.stopPropagation();
                       }
                   }

                </script>  
                <p:outputPanel autoUpdate="true">
                <p:toolbar >
                    <p:toolbarGroup align="left">
                        <p:commandButton value="#{bundle.btnNew}" icon="ui-icon-document"
                                         action="#{savclosureBean.newData()}" process="@this"
                                         update="displaySavclosure" >
                            <pe:resetEditableValues for="displaySavclosure"/>  
                        </p:commandButton> 
                        
                        <p:commandButton value="#{bundle.btnSave}" icon="ui-icon-disk"
                                         action="#{savclosureBean.trySave()}"  
                                         update="displaySavclosure" disabled="#{!savclosureBean.editMode}">
                        </p:commandButton> 
                    </p:toolbarGroup>
                </p:toolbar>
                </p:outputPanel>
                
                <p:remoteCommand name="rcsavclosureGetSaving" actionListener="#{savclosureBean.getSavingSrc('null')}" 
                                 process="savclosureSavingNo @this" update="savcloseCustInfo hideSavclossavaccntId" 
                                  oncomplete="focusState(xhr, status, args);"/>
                
                <!-- LOOK UP saving -->
                <p:dialog header="#{bundle.Select} #{bundle.accountNo}" widgetVar="dlgSavclosdepoLookupSav" closable="true" dynamic="true" >
                    <p:ajax listener="#{searchSavingBean.handleClose}" />
                    <h:panelGrid id="displaySavclosureLookup" rendered="#{searchSavingBean.showLookup==true}">
                        <ui:include src="../saving/searchSaving.xhtml" >
                            <ui:param name="lookupSavComponenId" value="savclose" />
                        </ui:include> 

                        <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR" >
                            <f:facet name="footer">
                                <p:commandButton value="#{bundle.btnOK}" icon="ui-icon-disk" immediate="true" 
                                                process="@this" update="savclosureSavingNo, hideSavclossavaccntId"
                                                action="#{savclosureBean.getSavingSrc(searchSavingBean.selectedData.accountNo)}" 
                                                oncomplete="dlgSavclosdepoLookupSav.hide(); focusState(xhr, status, args);" />

                                <p:commandButton value="#{bundle.btnClose}" oncomplete="dlgSavclosdepoLookupSav.hide()" immediate="true" icon="ui-icon-document" process="@this" />
                            </f:facet>
                        </h:panelGrid>
                    </h:panelGrid>
                    
                </p:dialog>
                
                <h:panelGrid id="displaySavclosure" styleClass="addELIT" cellpadding="0" columns="2" columnClasses="panelGridId,panelGridId">
                    
                    <p:panel header="#{bundle.savledgend}" style="margin: 0 0 0 0;">
                        <h:panelGrid columns="3" border="0">
                            
                            <h:outputLabel value= "#{bundle.savingNo}" /><h:outputLabel value=":" />
                            <h:panelGrid columns="2" cellpadding="0" cellspacing="0">                                
                                <p:inputText value="#{savclosureBean.savclosure.accountNo}" style="width: 170px;"
                                        onkeydown="customRK(event, 'savclosureSavingNo', '')" label="#{bundle.savingNo}" 
                                        id="savclosureSavingNo" required="true" disabled="#{!savclosureBean.editMode}"
                                        requiredMessage="#{bundle.savingNo} #{bundle.requiredInput}">
                                        <p:ajax update="msgsavclosurSavingNo hideSavclossavaccntId" process="@this"/>
                                </p:inputText>
                                <p:commandButton icon="ui-icon-search" iconPos="center" styleClass="btnSmall"
                                                     process="@this" immediate="true" oncomplete="dlgSavclosdepoLookupSav.show();" >
                                    </p:commandButton>
                                
                                <p:message id="msgsavclosurSavingNo" for="savclosureSavingNo" display="icon" />
                            </h:panelGrid>   

                            <h:outputLabel value="#{bundle.openDate}" /><h:outputLabel value=":" />
                            <h:outputText value="#{savclosureBean.savclosure.openDate}" />
                            
                            <h:outputLabel value="#{bundle.closureDate}" /><h:outputLabel value=":" />
                            <h:outputText value="#{savclosureBean.savclosure.closeDate}" />

                            <h:outputLabel style="padding: 0 15px 0 0;" value= "#{bundle.savpurpose}" /><h:outputLabel value=":" />
                            <h:outputLabel value="#{savclosureBean.savclosure.savpurpose.purposeName}" />

                            <h:outputLabel value="#{bundle.balance}" /><h:outputLabel value=":" />
                            <h:outputLabel value="#{savclosureBean.savclosure.balance}" styleClass="numPos" >
                                <f:convertNumber groupingUsed="true" />
                            </h:outputLabel>

                            <h:outputLabel value="#{bundle.joinAccnt}" /><h:outputLabel value=":" />
                            <p:selectBooleanCheckbox value="#{savclosureBean.savclosure.joinAccnt}" disabled="true" />

                            <h:outputLabel value="#{bundle.joinType}" /><h:outputLabel value=":" />
                            <h:outputLabel value="#{constantaBean.getJointTypeText(savclosureBean.savclosure.joinType)}" />
                            
                            <h:inputHidden value="#{savclosureBean.savclosure.savaccntId}" id="hideSavclossavaccntId"
                                required="true" requiredMessage="#{bundle.savingNo} #{bundle.requiredInput}" />
                            <h:inputHidden />
                                
                        </h:panelGrid>

                        <h:panelGrid columns="0" style="width: 100%;" >
                            <p:toolbar>
                                <p:toolbarGroup align="left" >
                                    <h:outputText value="#{bundle.joinType}" />
                                </p:toolbarGroup>
                            </p:toolbar>

                            <p:dataTable var="savjoinapprov" value="#{savclosureBean.savclosure.savjoints}" >
                                <p:column headerText="#{bundle.cif}" style="width:100px">
                                    <h:outputText value="#{savjoin.customer.cif}" style="width:100px;" />
                                </p:column>

                                <p:column style="width:auto" >
                                    <h:outputLabel value="#{savjoin.customer.customerName}" style="width:100px;" />
                                </p:column> 

                            </p:dataTable>
                        </h:panelGrid>
                    </p:panel>
                        
                    <h:panelGrid columns="1" cellpadding="1" rowClasses="panelGridId" border="0" >
                        <p:panel header="#{bundle.cusledgen}" id="savcloseCustInfo">
                            <h:panelGrid columns="3" style="width:100%;">
                                <h:outputLabel value= "#{bundle.cif}" /><h:outputLabel value=":" />
                                <h:outputLabel value="#{savclosureBean.savclosure.customer.cif}" />
                                <h:outputLabel value= "#{bundle.globalName}" /><h:outputLabel value=":" />
                                <h:outputText style="padding: 0 75px 0 0;"  value="#{savclosureBean.savclosure.customer.customerName}" />

                                <h:outputLabel value= "#{bundle.aliasName}" /><h:outputLabel value=":" />
                                <h:outputText rendered="true" value="#{savclosureBean.savclosure.customer.aliasName}" />

                                <h:outputLabel value= "#{bundle.phone}" /><h:outputLabel value=":" />
                                <h:outputText value="#{savclosureBean.savclosure.customer.phone}"/> 

                                <h:outputLabel value= "#{bundle.mobilePhone}" /><h:outputLabel value=":" />
                                <h:outputText value="#{savclosureBean.savclosure.customer.mobilePhone}"/>

                                <h:outputLabel style="padding: 0 15px 0 0;"  value= "#{bundle.npwp}" /><h:outputLabel value=":" />
                                <h:outputText value="#{savclosureBean.savclosure.customer.npwp}" />

                                <h:outputLabel style="padding: 0 15px 0 0;"  value= "#{bundle.addressRes}" /><h:outputLabel value=":" />
                                <h:outputText value="#{savclosureBean.savclosure.customer.idAddressLine1}" />
                                
                                <h:outputLabel value= "#{bundle.specimen}" /><h:outputLabel value=":"/>
                                <p:graphicImage  value="/upload/personal/#{savclosureBean.savclosure.customer.specimen}" />
                                
                            </h:panelGrid>
                        </p:panel>

                        <p:panel header="#{bundle.savprodLedgend}">
                            <h:panelGrid columns="3" style="width: 100%;" >
                                <h:outputLabel value= "#{bundle.savprod}" /><h:outputLabel value=":" />
                                <h:outputText rendered="true" value="#{savclosureBean.savclosure.savprod.productName}" />

                                <h:outputLabel value= "#{bundle.minFirstDeposit}" /><h:outputLabel value=":" />
                                <h:outputText styleClass="numPos" value="#{savclosureBean.savclosure.savprod.minFirstDeposit}" >
                                    <f:convertNumber groupingUsed="true" />
                                </h:outputText>

                                <h:outputLabel value= "#{bundle.minRegDeposit}" /><h:outputLabel value=":" />
                                <h:outputText styleClass="numPos" value="#{savclosureBean.savclosure.savprod.minRegDeposit}" >
                                    <f:convertNumber groupingUsed="true" />
                                </h:outputText>

                                <h:outputLabel value= "#{bundle.interestTax}" /><h:outputLabel value=":" />
                                <h:outputText styleClass="numPos" value="#{savclosureBean.getInterestTaxName(savclosureBean.savclosure.savprod.interestTaxId)} %" />

                                <h:outputLabel value= "#{bundle.interestMethod}" /><h:outputLabel value=":" />
                                <h:outputText styleClass="numPos" value="#{constantaBean.getInterestMetodText(savclosureBean.savclosure.savprod.interestMethod)}" />

                                <h:outputLabel style="padding: 0 15px 0 0;" value= "#{bundle.maxBalAdmFee}" /><h:outputLabel value=":" />
                                <h:outputText styleClass="numPos" value="#{savclosureBean.savclosure.savprod.maxBalAdmFee}" >
                                    <f:convertNumber groupingUsed="true" />
                                </h:outputText>
                                <h:outputLabel value= "#{bundle.admFee}" /><h:outputLabel value=":" />
                                <h:outputText styleClass="numPos" value="#{savclosureBean.savclosure.savprod.admFee}" >
                                    <f:convertNumber groupingUsed="true" />
                                </h:outputText>
                                <h:outputLabel value= "#{bundle.closingAdmFee}" /><h:outputLabel value=":" />
                                <h:outputText styleClass="numPos" value="#{savclosureBean.savclosure.savprod.closingAdmFee}" >
                                    <f:convertNumber groupingUsed="true" />
                                </h:outputText>
                            </h:panelGrid>
                        </p:panel> 
                    </h:panelGrid>
                </h:panelGrid>    
            </h:form>
        </ui:composition>
    </h:body>
</html>